package com.sysu.minsysu.zdkb;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.sysu.R;
import com.sysu.minsysu.zdkb.utils.Course;

public class DetailsDialog extends Dialog{

	Course mCourse;
	
	TextView mCourseNameTextView;
	TextView mTeacherNameTextView;
	TextView mCourseTimeTextView;
	TextView mCoursePlaceTextView;
	TextView mCourseWeekTextView;
	Button mSelectButton;
	Button mBackButton;
	
	public DetailsDialog(Context context, Course course ) {
		super(context);
		mCourse = course;
		setContentView(R.layout.detailsdialog);
		setupViews();
		setupCourseInfo();
		
		mBackButton.setOnClickListener( new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
	}
	
	private void setupViews(){
		mCourseNameTextView = (TextView)findViewById(R.id.courseName);
		mCoursePlaceTextView = (TextView)findViewById(R.id.coursePlace);
		mCourseTimeTextView = (TextView)findViewById(R.id.courseTime);
		mCourseWeekTextView = (TextView)findViewById(R.id.courseWeek);
		mTeacherNameTextView = (TextView)findViewById(R.id.teacherName);
		mSelectButton = (Button)findViewById(R.id.select);
		mBackButton = (Button)findViewById(R.id.back);
	}
	
	private void setupCourseInfo(){
		mCourseNameTextView.setText( mCourse.getCourseName() );
		mTeacherNameTextView.setText( mCourse.getTeacherName() );
		mCoursePlaceTextView.setText( mCourse.getPlace() );
		mCourseTimeTextView.setText( mCourse.getTimeInterval() );
		mCourseWeekTextView.setText(mCourse.getDate());
	}
	
	public void setSelectListener( View.OnClickListener listener ){
		mSelectButton.setOnClickListener(listener);
	}

}
